<?php

namespace App\Shop\Controllers;

use App\Shop\Logic\MachineLogic;
use App\Shop\Logic\MerchantLogic;
use Dingo\Api\Http\Request;

class MachineController extends BaseController
{

    /**
     * @notes 获取商户所有设备
     * @param Request $request
     * @return \Dingo\Api\Http\Response
     * @author Evil丿
     * @date 2024/08/07 15:11
     */
    public function getMachineList(Request $request)
    {
        $params = $request -> all();

        $merchant_id = MerchantLogic::getMerchantIdById($params['user_id']);

        if(!$merchant_id) {
            return $this->error('用户不存在');
        }

        $params['merchant_id'] = $merchant_id;

        $data = MachineLogic::getMachineListByMerchantId($params);

        return $this->success($data);
    }

    /**
     * @notes 获取商户分润列表
     * @param Request $request
     * @return \Dingo\Api\Http\Response
     * @author Evil丿
     * @date 2024/11/22 10:16
     */
    public function getMachineProfitList(Request $request)
    {
        $params = $request -> all();

        $merchant_id = MerchantLogic::getMerchantIdById($params['user_id']);

        if(!$merchant_id) {
            return $this->error('用户不存在');
        }

        $params['merchant_id'] = $merchant_id;

        $data = MachineLogic::getMachineProfitListByMerchantId($params);

        return $this->success($data);
    }
}
